<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>乘积小于 K 的子数组</title>
</head>

<body>
  <script>
    var numSubarrayProductLessThanK = function (nums, k) {
      if (k < Math.min.apply(this, nums)) {
        return 0
      }
      let n = 0
      let sum = 0
      while (n < nums.length) {
        let cj = 1
        for (let i = n; i < nums.length; i++) {
          if (cj * nums[i] < k) {
            sum++
            cj = cj * nums[i]
          } else {
            break
          }
        }
        n++
      }
      return sum
    };
    console.log(numSubarrayProductLessThanK([10, 5, 2, 6], 100))
  </script>
</body>

</html>